package com.will.account.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.will.account.domain.Account;
import com.will.account.mapper.AccountMapper;
import com.will.account.response.AjaxResult;
import com.will.account.service.IAccountService;
import com.will.common.dto.AccountDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> implements IAccountService {

    @Autowired
    private AccountMapper accountMapper;

    @Override
    public AjaxResult decreaseAccount(AccountDto accountDto) {
        try {
            int num = accountMapper.decreaseAccount(accountDto);
            if (num > 0) {
                return AjaxResult.success();
            }
            return AjaxResult.error();
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }
}
